<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateWyFinaUserAccountTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('wy_fina_user_account', function (Blueprint $table) {
            $table->increments('id');
            $table->tinyInteger('type')->comment('由调用方自行约定的账户类型，例如积分、例如平台币等');
            $table->integer('usr_id')->index('usr_id')->comment('用户ID');
            $table->decimal('balance', 17, 2)->default(0)->comment('余额');
            $table->decimal('stat_history_income', 17, 2)->default(0)->comment('历史累计收入（账户的收入很可能是平台的支出）');
            $table->decimal('stat_history_outcome', 17, 2)->default(0)->comment('历史累计支出（账户的支出很可能是平台的充值等收费收入）');
            $table->decimal('stat_daily_income', 17, 2)->default(0)->comment('本日累计收入（账户的收入很可能是平台的支出）');
            $table->decimal('stat_daily_outcome', 17, 2)->default(0)->comment('本日累计支出（账户的支出很可能是平台的充值等收费收入）');
            $table->dateTime('last_transaction_time')->comment('最后交易时间，每次有账务变动时更新，用于分辨本天是否有交易，以及分辨本日累计收入支出。
如果是其他信息的修改，应该修改框架的updated_at字段');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('wy_fina_user_account');
    }
}
